import os

from xjlibrary.our_file_dir import BaseDir, ImageFile

curPath = BaseDir.get_file_dir_absolute(__file__)
TopPath = BaseDir.get_upper_dir(curPath, -3)
sPath = BaseDir.get_new_path(TopPath, "download", "zswj", 'download', "cover")
sPath2 = BaseDir.get_new_path(TopPath, "download", "zswj", 'download', "cover2")
BaseDir.create_dir(sPath2)

for path in BaseDir.get_dir_all_files(sPath):
    print(path)
    filename = BaseDir.get_file_name(path)
    print(filename)
    count = BaseDir.single_read_rb_file(path)
    outPathFile = os.path.join(sPath2, filename)
    print(outPathFile)
    if ImageFile.img_to_format_jpg(count, outPathFile):
        print("转换成功")
